package org.xlp.db.bridge.strategy;

import org.xlp.db.xml.XmlSQL;

import java.lang.reflect.Type;

/**
 * Description: 获取XmlSQL构造函数策略接口
 * <br/>date: 2024/4/19 20:55
 *
 * @version 1.0
 * @author: xlp
 */
public interface IXmlSQLConstructorStrategy extends Comparable<IXmlSQLConstructorStrategy>{
    /**
     * 获取权重
     * @return
     */
    default int getWeight(){
        return 0;
    }

    /**
     * 设置权重
     * @param weight
     */
    default void setWeight(int weight) {}

    /**
     * 实现比较逻辑，用来排序
     * @param o
     * @return
     */
    @Override
    default int compareTo(IXmlSQLConstructorStrategy o){
        if (o == null || this.getWeight() > o.getWeight()) return 1;
        return this.getWeight() == o.getWeight() ? 0 : -1;
    }

    /**
     * 根据给定的参数类型获取相应的{@link XmlSQLConstructorInfo}对象
     * @param methodReturnType
     * @param parameterClasses
     * @param parameters
     * @return
     */
    XmlSQLConstructorInfo getXmlSQLConstructor(Type methodReturnType, Class<?>[] parameterClasses,
                                               Object[] parameters);
}
